package com.yunxi.service.dubboService.impl.sys;

import com.github.pagehelper.PageInfo;
import com.yunxi.model.sys.Role;
import com.yunxi.service.localService.sys.RoleMenuService;
import com.yunxi.sys.pojo.MenuVO;
import com.yunxi.sys.pojo.RoleMenuVO;
import com.yunxi.sys.pojo.RoleVO;
import com.yunxi.sys.service.RoleDubboService;
import com.yunxi.sys.service.RoleMenuDubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 字典表 服务实现类
 * </p>
 * @author
 * @since 2019-05-08
 */
public class RoleMenuDubboServiceImpl implements RoleMenuDubboService {

    @Autowired
    @Qualifier(value = "roleMenuServiceImpl")
    RoleMenuService roleMenuService;

    @Override
    public Object listByRoleId(String roleId) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        return roleMenuService.findRoleMenuList(roleId);
    }

    @Override
    public void saveRoleMenuList(RoleMenuVO roleMenu, String userId) {
        roleMenuService.saveRoleMenuList(roleMenu,userId);
    }

    //    @Cacheable(key="'menu:'+#UserId+'_'+#companyId+'_'+#type")
    public List listByUserId(String userId) {
        return roleMenuService.listByUserId(userId);
    }

    public List listByRoleCode(String roleCode) {
        return roleMenuService.listByRoleCode(roleCode);
    }

    @Override
    public String[] listMenuByUserId(String userId) {
        List<MenuVO> list = listByUserId(userId);
        String[] aaa = new String[list.size()];
        for(int i=0;i<list.size();i++){
            MenuVO m = list.get(i);
            aaa[i] = m.getMenuUrl();
        }
        return aaa;
    }

    @Override
    public String[] listMenuByRoleCode(String roleCode) {
        List<MenuVO> list = listByRoleCode(roleCode);
        String[] aaa = new String[list.size()];
        for(int i=0;i<list.size();i++){
            MenuVO m = list.get(i);
            aaa[i] = m.getMenuUrl();
        }
        return aaa;
    }
}
